* Affective Polarization in the US Military
* Kevin Mullinix and Trent Lythgoe

*****ANES Data Analysis

clear

****Build Table 1 of feeling thermometers toward out-party by military service


*******************
**** 2004 ANES TS**
*******************

*use "[working dir]\anes2004TS.dta"

* Variables of interest
* V040101 Study weights and sampling error code
* V043049 B1n. Feeling Thermometer: Democratic party
* V043050 B1p. Feeling Thermometer: Republican party
* V043116 J1x. Summary: R party ID
* V043258 Y5a. R military service

* Sample Weights
gen weight = V040101
label variable weight "Weight"

* Partisanship
* V043116 J1x. Summary: R party ID
* 0. Strong Democrat 
* 1. Weak Democrat 
* 2. Independent-Democrat 
* 3. Independent-Independent
* 4. Independent-Republican 
* 5. Weak Republican 
* 6. Strong Republican 
* 7. Other; minor party; refuses to say 
* MISSING CODES:
* 8. Apolitical 
* 9. DK 

* Party
tab V043116
gen pid2 =.
replace pid2=0 if V043116==0
replace pid2=0 if V043116==1
replace pid2=0 if V043116==2
replace pid2=1 if V043116==4
replace pid2=1 if V043116==5
replace pid2=1 if V043116==6
tab pid2
label define pid2 0 "Democrat" 1 "Republican"
label values pid2 pid2

* Military Serivce
* VALID CODES:
* 1. Yes
* 5. No
* MISSING CODES:
* 8. Don't know
* 9. Refused

* Military
tab V043258
gen mil2= .
replace mil2= 0 if V043258==5
replace mil2= 1 if V043258==1
tab mil2
label define mil2 0 "Not Served" 1 "Served"
label values mil2 mil2
tab mil2

* Feeling Therms
* V043049 B1n. Feeling Thermometer: Democratic party
tab V043049
gen demFT= V043049
replace demFT=. if V043049==777
replace demFT=. if V043049==888
replace demFT=. if V043049==889
tab demFT

* V043050 B1p. Feeling Thermometer: Republican party
tab V043050
gen repFT= V043050
replace repFT=. if V043050==777
replace repFT=. if V043050==888
replace repFT=. if V043050==889
tab repFT


* Out FT classification
gen demoutFT = repFT if pid2 == 0
label variable demoutFT "Democrat Outparty FT"
tab demoutFT
gen repoutFT = demFT if pid2 == 1
label variable repoutFT "Republican Outparty FT"
tab repoutFT
egen outFT= rowmax(repoutFT demoutFT)
tab outFT

*Info for table
table mil2 [pweight = weight], c(mean outFT )




*******************
* 2008 ANES TS*****
*******************


*use "[working dir]\anes_timeseries_2008.dta"
* V080101    WT.1. PRE CROSS-SECTION SAMPLE WEIGHT - POST-STRAT, centered
* V083044a    B1h. Feeling Thermometer: Democratic Party
* V083044b    B1j. Feeling Thermometer: Republican Party
* V083098x    J1x. SUMMARY: R Party Identification
* V083221    Y5. Is R or has R ever been in the military.

* Sample Weights
gen weight = V080101
label variable weight "Weight"

*Partisanship
* V083098x    J1x. SUMMARY: R Party Identification
* 0. Strong Democrat 
* 1. Weak Democrat 
* 2. Independent-Democrat 
* 3. Independent-Independent 
* 4. Independent-Republican 
* 5. Weak Republican 
* 6. Strong Republican 
* MISSING CODES:
* -1. INAP, -9 in J1; -8,-9 in J1a; -8,-9 in J1b

* Party
tab V083098x
gen pid2 =.
replace pid2=0 if V083098x==0
replace pid2=0 if V083098x==1
replace pid2=0 if V083098x==2
replace pid2=1 if V083098x==4
replace pid2=1 if V083098x==5
replace pid2=1 if V083098x==6
tab pid2
label define pid2 0 "Democrat" 1 "Republican"
label values pid2 pid2

* Military Serivce
* V083221    Y5. Is R or has R ever been in the military
* 1. Currently serving
* 2. Not currently serving but previously served
* 3. R has never served in the military
** MISSING CODES:
* * -8. Don't know
* -9. Refused

* Military
tab V083221
gen mil2= .
replace mil2= 0 if V083221==3
replace mil2= 1 if V083221==1
replace mil2= 1 if V083221==2
tab mil2
label define mil2 0 "Not Served" 1 "Served"
label values mil2 mil2
tab mil2

* Feeling Therms
* V083044a    B1h. Feeling Thermometer: Democratic Party
tab V083044a
gen demFT= V083044a
replace demFT=. if V083044a==-9
replace demFT=. if V083044a==-8
replace demFT=. if V083044a==-6
tab demFT

* V083044b    B1j. Feeling Thermometer: Republican Party
tab V083044b
gen repFT= V083044b
replace repFT=. if V083044b==-9
replace repFT=. if V083044b==-8
replace repFT=. if V083044b==-6
tab repFT

* Out FT classification
gen demoutFT = repFT if pid2 == 0
label variable demoutFT "Democrat Outparty FT"
tab demoutFT
gen repoutFT = demFT if pid2 == 1
label variable repoutFT "Republican Outparty FT"
tab repoutFT
egen outFT= rowmax(repoutFT demoutFT)
tab outFT

*Info for table
table mil2 [pweight = weight], c(mean outFT )


*********************
* 2012 ANES TS*******
*********************
*use "[working dir]\anes_timeseries_condensed_2012.dta"

* Variables of Interest
* weight_full Label: ANES 2012 Time Series Post-stratified weight for full sample
* ft_dem Label: Feeling Thermometer: Democratic Party
* ft_rep Label: Feeling Thermometer: Republican Party
* pid_x Label: PRE: SUMMARY- Party ID
* dem_veteran Label: R ever served on active duty in Armed Forces

gen weight = weight_full
label variable weight "Weight"

* Partisanship
* pid_x
* 1. Strong Democrat 
* 2. Not very strong Democract 
* 3. Independent-Democrat 
* 4. Independent 
* 5. Independent-Republican 
* 6. Not very strong Republican 
* 7. Strong Republican 
* -2. Missing 

tab pid_x
gen pid2 =.
replace pid2=0 if pid_x==1
replace pid2=0 if pid_x==2
replace pid2=0 if pid_x==3
replace pid2=1 if pid_x==5
replace pid2=1 if pid_x==6
replace pid2=1 if pid_x==7
tab pid2
label define pid2 0 "Democrat" 1 "Republican"
label values pid2 pid2


* Military Serivce
* dem_veteran
* Label: R ever served on active duty in Armed Forces
* 1. Yes
* 2. No 
* -8. Don't know 
* -9. Refused 

tab dem_veteran
gen mil2= .
replace mil2= 0 if dem_veteran==2
replace mil2= 1 if dem_veteran==1
tab mil2
label define mil2 0 "Not Served" 1 "Served"
label values mil2 mil2
tab mil2


* Feeling Therms
* ft_dem   Feeling Thermometer: Democratic Party
tab ft_dem
gen demFT= ft_dem
replace demFT=. if ft_dem==-9
replace demFT=. if ft_dem==-8
replace demFT=. if ft_dem==-2
tab demFT

* ft_rep    Feeling Thermometer: Republican Party
tab ft_rep
gen repFT= ft_rep
replace repFT=. if ft_rep==-9
replace repFT=. if ft_rep==-8
replace repFT=. if ft_rep==-2
tab repFT

* Out FT classification
gen demoutFT = repFT if pid2 == 0
label variable demoutFT "Democrat Outparty FT"
tab demoutFT
gen repoutFT = demFT if pid2 == 1
label variable repoutFT "Republican Outparty FT"
tab repoutFT
egen outFT= rowmax(repoutFT demoutFT)
tab outFT


*Info for table
table mil2 [pweight = weight], c(mean outFT )



******************
* 2016 ANES TS****
******************

* Variables of interest
* V160101 Pre-election weight -full sample
* V161095 PRE: Feeling Thermometer: Democratic Party
* V161096 PRE: Feeling Thermometer: Republican Party
* V161158x Label: PRE: SUMMARY - Party ID
* V161274a PRE: Previously served on active duty in armed forces

*use "[working dir]\anes_timeseries_2016.dta"
gen weight = V160101
label variable weight "Weight"

*Partisanship
* V161158x
* 1. Strong Democrat 
* 2. Not very strong Democract 
* 3. Independent-Democrat 
* 4. Independent 
* 5. Independent-Republican 
* 6. Not very strong Republican 
* 7. Strong Republican 
* -8. DK (-8) 
* -9. RF (-9) 

tab V161158x
gen pid2 =.
replace pid2=0 if V161158x==1
replace pid2=0 if V161158x==2
replace pid2=0 if V161158x==3
replace pid2=1 if V161158x==5
replace pid2=1 if V161158x==6
replace pid2=1 if V161158x==7
tab pid2
label define pid2 0 "Democrat" 1 "Republican"
label values pid2 pid2


* Military Serivce
* V161274a
* 0. Have never served on active duty 
* 1. Have previously served on active duty 
*-9. Refused

tab V161274a
gen mil2= .
replace mil2= 0 if V161274a==0
replace mil2= 1 if V161274a==1
tab mil2
label define mil2 0 "Not Served" 1 "Served"
label values mil2 mil2
tab mil2


* Feeling Therms
* V161095   Feeling Thermometer: Democratic Party
tab V161095
gen demFT= V161095
replace demFT=. if V161095==-99
replace demFT=. if V161095==-89
replace demFT=. if V161095==-88
tab demFT

* V161096    Feeling Thermometer: Republican Party
tab V161096
gen repFT= V161096
replace repFT=. if V161096==-99
replace repFT=. if V161096==-89
replace repFT=. if V161096==-88
tab repFT

* Out FT classification
gen demoutFT = repFT if pid2 == 0
label variable demoutFT "Democrat Outparty FT"
tab demoutFT
gen repoutFT = demFT if pid2 == 1
label variable repoutFT "Republican Outparty FT"
tab repoutFT
egen outFT= rowmax(repoutFT demoutFT)
tab outFT


*Info for table
table mil2 [pweight = weight], c(mean outFT )



**********************************************************************************************
*Regression using 2016 ANES data; influence of military service on national identity measure**
**********************************************************************************************


* DV American Identity
* V162332
* How important is being American to your identity?
* 1. Extremely important 472 1107 1579
* 2. Very important 320 739 1059
* 3. Moderately important 135 460 595
* 4. A little important 57 167 224
* 5. Not at all important 36 104 140
* -5. Breakoff, sufficient partial
* IW 31 0 31
* -6. No post-election interview 122 414 536
* -7. No post data, deleted due
* to incomplete IW 0 86 86
* -9. Refused 7 13 20
tab V162332
gen amident=.
replace amident=1 if V162332==5
replace amident=2 if V162332==4
replace amident=3 if V162332==3
replace amident=4 if V162332==2
replace amident=5 if V162332==1
tab amident

** Gender
* V161342
* What is your gender?
* 1. Male 551 1436 1987
* 2. Female 609 1622 2231
* 3. Other 1 10 11
* -9. Refused 19 22 41
tab V161342
gen gender2=.
replace gender2=0 if V161342==1
replace gender2=1 if V161342==2
tab gender2
label define gender2 0 "Male" 1 "Female"
label values gender2 gender2
tab gender2


* Race
* V161310x
* Please choose one or more races that you consider yourself to be:
* 1. White, non-Hispanic 796 2242 3038
* 2. Black, non-Hispanic 119 278 397
* 3. Asian, native Hawaiian or
* other Pacif Islr,non-Hispanic 30 118 148
* 4. Native American or Alaska
* Native, non-Hispanic 10 17 27
* 5. Hispanic 169 281 450
* 6. Other non-Hispanic incl
* multiple races <WEB: blank
* ’Other’ counted as a race> 52 125 177
* -2. Missing 4 29 33
tab V161310x
gen race3=.
replace race3=0 if V161310x==1
replace race3=1 if V161310x==2
replace race3=2 if V161310x==3
replace race3=2 if V161310x==4
replace race3=2 if V161310x==5
replace race3=2 if V161310x==6
tab race3
label define race3 0 "Non-Hispanic White" 1 "Non-Hispanic Black" 2 "Other"
label values race3 race3
tab race3

* Party ID
* V161158x
* 1. Strong Democrat 220 670 890
* 2. Not very strong Democract 138 421 559
* 3. Independent-Democrat 175 315 490
* 4. Independent 120 459 579
* 5. Independent-Republican 194 306 500
* 6. Not very strong
* Republican 132 376 508
* 7. Strong Republican 187 534 721
* -8. DK (-8) in V161156 or
* -9. RF (-9)
tab V161158x
gen party7=.
replace party7=1 if V161158x==1
replace party7=2 if V161158x==2
replace party7=3 if V161158x==3
replace party7=4 if V161158x==4
replace party7=5 if V161158x==5
replace party7=6 if V161158x==6
replace party7=7 if V161158x==7
tab party7

* Education
* V161270
* What is the highest level of school you have completed or the highest degree you have received?
* 1. Less than 1st grade 1 0 1
* 2. 1st, 2nd, 3rd or 4th grade 2 1 3
* 3. 5th or 6th grade 10 5 15
* 4. 7th or 8th grade 8 14 22
* 5. 9th grade 8 24 32
* 6. 10th grade 13 27 40
* 7. 11th grade 24 38 62
* 8. 12th grade no diploma 40 67 107
* 9. High school graduate
* 10. Some college but no degree 204 694 898
* 11. Associate degree in college occupational/vocational program 101 212 313
* 12. Associate degree in college – academic program 83 205 288
* 13. Bachelor’s degree 
* 14. Master’s degree 
* 15. Professional school degree
* 16. Doctorate degree
* 90. Other specify given as: high school graduate 0 5 5
* 95. Other SPECIFY 7 17 24
* -9. Refused 0 15 15
tab V161270
gen edu=.
replace edu=1 if V161270==1
replace edu=1 if V161270==2
replace edu=1 if V161270==3
replace edu=1 if V161270==4
replace edu=1 if V161270==5
replace edu=1 if V161270==6
replace edu=1 if V161270==7
replace edu=1 if V161270==8
replace edu=2 if V161270==9
replace edu=3 if V161270==10
replace edu=4 if V161270==11
replace edu=4 if V161270==12
replace edu=5 if V161270==13
replace edu=6 if V161270==14
replace edu=6 if V161270==15
replace edu=6 if V161270==16
replace edu=2 if V161270==90
tab edu


* Income
* V161361x
* 28 Categories from  1 (Under 5,000) to 28 (> 250,000)
* -9 Refused
tab V161361x
gen income=V161361x
replace income=. if V161361x==-9
replace income=. if V161361x==-5
tab income

* Age
* V161267
tab V161267
gen age= V161267
replace age=. if V161267==-9
replace age=. if V161267==-8
tab age

* Ideology
* V161126
* Where would you place yourself on this scale, or haven’t you thought much
* about this? 
* 1. Extremely liberal 42 104 146
* 2. Liberal 131 375 506
* 3. Slightly liberal 101 279 380
* 4. Moderate, middle of the
* road 245 649 894
* 5. Slightly conservative 152 356 508
* 6. Conservative 186 517 703
* 7. Extremely conservative 51 115 166
* 99. Haven’t thought much 
* -8. Don’t know (FTF only) 5 0 5
* -9. Refused 2 16 18
tab V161126
gen ideo=V161126
replace ideo=. if V161126==-9
replace ideo=. if V161126==-8
replace ideo=. if V161126==99
tab ideo



*Regression model
ologit amident i.mil2  [pweight=weight]
*outreg2 using IdentitybyService.doc, replace ctitle(Identity) label 


ologit amident i.mil2 i.gender2 i.race3 ideo party7 edu income age [pweight=weight]
*outreg2 using IdentitybyService.doc, append ctitle(Identity) label 
*margins, dydx(i.mil2) vsquish
*marginsplot, scheme(s1mono)  title("Effect of Military Service on Importance of American Identity") yline(0,lpattern(dash))  xscale(range(.75 5.25)) xtitle("Importance of Identity (1 = Not at all Important, 5 = Extremely Important)", margin(medium)) ytitle("Predicted Effect of Serving in the Military", margin(medium))
*graph export Identity_Service.pdf, replace




